﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using MacomberMapSystem.Common.Integration;
using MacomberMapSystem.Common.CIM;
using MacomberMapSystem.Common.Database;

namespace MacomberMapSystem.Common.User_Interfaces.CIM_Browser
{
    /// <summary>
    /// This class wraps the CIM browser control in a docking form
    /// </summary>
    public partial class frmCIMBrowser : DockContent
    {
        /// <summary>Our CIM browser form</summary>
        public ctlCIMBrowser CIM;

        /// <summary>
        /// Initialize a new CIM browser form
        /// </summary>
        /// <param name="Model"></param>
        public frmCIMBrowser(MM_Database_Model Model)
        {
            InitializeComponent();
            CIM = new ctlCIMBrowser(Model);
            CIM.Dock = DockStyle.Fill;
            this.Controls.Add(CIM);
            this.Text = Model.ToString();
        }

        #region Form display
        /// <summary>
        /// Show the CIM browser with a particular element
        /// </summary>
        /// <param name="StartElement">The element to display</param>
        /// <param name="pnlDock">The docking panel</param>
        public void Show(CIM_Element StartElement, DockPanel pnlDock)
        {
            //First, clear our elements
            CIM.ClearElements();
            CIM.SetConnector(StartElement.CIM);
            CIM.AddElement(StartElement,null);
            base.Show(pnlDock);
            base.Activate();
        }

        /// <summary>
        /// Show the CIM browser with a particular element
        /// </summary>
        /// <param name="Conn">The CIM connector</param>
        /// <param name="pnlDock">The docking panel</param>
        public void Show(MM_Database_Model Conn, DockPanel pnlDock)
        {
            //First, clear our elements
            CIM.ClearElements();
            CIM.SetConnector(Conn);           
            base.Show(pnlDock);
            base.Activate();
        }


        /// <summary>
        /// Show the CIM browser with a particular element
        /// </summary>
        /// <param name="Conn">The CIM connector</param>
        public void Show(MM_Database_Model Conn)
        {
            //First, clear our elements
            CIM.ClearElements();
            CIM.SetConnector(Conn);
            base.Show();
            base.Activate();
        }


        /// <summary>
        /// Show the CIM browser with a particular element
        /// </summary>
        /// <param name="StartElement"></param>
        public void Show(CIM_Element StartElement)
        {
            CIM.ClearElements();
            CIM.AddElement(StartElement,null);
            base.Show(Data_Manager.MainDock);
            base.Activate();
        }
        #endregion

      
    }
}
